package o;

import com.google.android.exoplayer2.audio.Ac3Util;
import com.google.android.exoplayer2.extractor.Extractor;
import com.google.android.exoplayer2.extractor.ts.TsPayloadReader.a;
import java.io.IOException;
import o.aea.e;

public final class afw implements Extractor {
    private static final int ˋ = anr.ᐝ("ID3");
    public static final adw ˎ = afs.ˋ;
    private final anc ˊ;
    private final aga ˏ;
    private final long ॱ;
    private boolean ॱॱ;

    public afw() {
        this(0);
    }

    public afw(long j) {
        this.ॱ = j;
        this.ˏ = new aga();
        this.ˊ = new anc(2786);
    }

    public boolean ˎ(adv o_adv) throws IOException, InterruptedException {
        int ʿ;
        anc o_anc = new anc(10);
        int i = 0;
        while (true) {
            o_adv.ˎ(o_anc.ˏ, 0, 10);
            o_anc.ˋ(0);
            if (o_anc.ˏॱ() != ˋ) {
                break;
            }
            o_anc.ˎ(3);
            ʿ = o_anc.ʿ();
            i += ʿ + 10;
            o_adv.ˊ(ʿ);
        }
        o_adv.ˏ();
        o_adv.ˊ(i);
        ʿ = 0;
        int i2 = i;
        while (true) {
            o_adv.ˎ(o_anc.ˏ, 0, 6);
            o_anc.ˋ(0);
            if (o_anc.ॱॱ() != 2935) {
                o_adv.ˏ();
                i2++;
                if (i2 - i >= 8192) {
                    return false;
                }
                o_adv.ˊ(i2);
                ʿ = 0;
            } else {
                ʿ++;
                if (ʿ >= 4) {
                    return true;
                }
                int ˋ = Ac3Util.ˋ(o_anc.ˏ);
                if (ˋ == -1) {
                    return false;
                }
                o_adv.ˊ(ˋ - 6);
            }
        }
    }

    public void ˏ(ady o_ady) {
        this.ˏ.ˏ(o_ady, new a(0, 1));
        o_ady.ˊ();
        o_ady.ˎ(new e(-9223372036854775807L));
    }

    public void ˊ(long j, long j2) {
        this.ॱॱ = false;
        this.ˏ.ˏ();
    }

    public void ॱ() {
    }

    public int ˎ(adv o_adv, adz o_adz) throws IOException, InterruptedException {
        int ˊ = o_adv.ˊ(this.ˊ.ˏ, 0, 2786);
        if (ˊ == -1) {
            return -1;
        }
        this.ˊ.ˋ(0);
        this.ˊ.ॱ(ˊ);
        if (!this.ॱॱ) {
            this.ˏ.ˋ(this.ॱ, 4);
            this.ॱॱ = true;
        }
        this.ˏ.ˊ(this.ˊ);
        return 0;
    }
}
